/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package pe.gob.fonafe.dao.impl.stored;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.Map;
import javax.sql.DataSource;
import oracle.jdbc.OracleTypes;
import org.springframework.dao.DataAccessException;
import org.springframework.jdbc.core.RowMapper;
import org.springframework.jdbc.core.SqlOutParameter;
import org.springframework.jdbc.object.StoredProcedure;
import pe.gob.fonafe.domain.UbigeoBean;

/**
 *
 * @author czela
 */
public class ListarUbigeoSP extends StoredProcedure{

    private static final String PROC_PARAM="USERFINAL.P_LISTA_UBIGEO";

    public ListarUbigeoSP(DataSource ds) {
        super(ds, PROC_PARAM);
        declareParameter(new SqlOutParameter("cCursor", OracleTypes.CURSOR,new ListarUbigeosRowMapper()));
        compile();
    }

    public Map execute(){
        Map inputs= new HashMap();
        return super.execute(inputs);
    }

    private static class ListarUbigeosRowMapper implements RowMapper<UbigeoBean>{

        public UbigeoBean mapRow(ResultSet rs, int rowNum) throws SQLException {
            UbigeoBean bean = new UbigeoBean();
            bean.setId(rs.getString("ID_UBIGEO"));
            bean.setDepartamento(rs.getString("DEPARTAMENTO"));
            bean.setProvincia(rs.getString("PROVINCIA"));
            bean.setDistrito(rs.getString("DISTRITO"));
            bean.setUbigeo(rs.getString("UBIGEO"));
            return bean;
        }

    }



}
